package com.gin.kotlin.no_gay_alliance.provider.ngaphp

import com.gin.nga.main.NgaApi
import java.lang.ref.WeakReference

class PrivilegeProvider private constructor():AbstractCachedDataProvider<Long,List<String>,String>(
    javaType = TYPE_FACTORY.constructType(String::class.java)
) {
    override val dir = "PRIVILEGE"

    override fun transform(rawData: List<String>) = rawData.joinToString("")

    override fun requestMethod(ngaApi: NgaApi, params: Long?) = ngaApi.topicListApi.privilege(params!!)

    override fun obtainRelativePath(userId: Long, params: Long?) = "${params}.json"

    companion object {
        private var instance: WeakReference<PrivilegeProvider> = WeakReference(PrivilegeProvider())
        fun getInstance(): PrivilegeProvider = instance.get() ?: PrivilegeProvider().also { instance = WeakReference(it) }
    }
}